using UnityEngine;
using System.Collections;

public class Partiquill : MonoBehaviour {

	public Color color = Color.white;
	float initialForce = 10f;
	float initialTorque = 1f;

	void Start () {
		while(transform.childCount > 0) {
			Transform c = transform.GetChild(0);

			if(c.rigidbody2D != null) {
				c.rigidbody2D.AddForce( Random.insideUnitCircle * initialForce, ForceMode2D.Impulse );
				c.rigidbody2D.AddTorque( Random.Range(-initialTorque,initialTorque), ForceMode2D.Impulse );

				if(c.GetComponent<SpriteRenderer>() != null)
					c.GetComponent<SpriteRenderer>().color = color;
			}

			c.SetParent(null);	// become Batman
		}

		Destroy(gameObject);
	}
}
